# -*- coding: utf-8 -*-
# !/usr/bin/env python
import sqlite3
import pandas as pd


class DB:
    def __init__(self, file_path="./static/data/test.db"):
        self.conn = sqlite3.connect(file_path, check_same_thread=False)
        self.cursor = self.conn.cursor()

    def read_sql(self, sql, kind=0):
        self.cursor.execute(sql)
        self.conn.commit()
        if kind == 0:
            result = self.cursor.fetchall()
            columns = self.cursor.description
            return pd.DataFrame(result, columns=[i[0] for i in columns])
        else:
            return "数据写入成功！！！"

    def close(self):
        return self.conn.close()
